home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
databnch
/
comm.fcm
next >
Wrap
Text File
|
1993-03-23
|
13KB
|
397 lines
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C C
C Benchmark Program for data parallel operations C
C C
C ADAPTOR Version 1.0 C
C C
C Author: Dr. Thomas Brandes, GMD, I1.HR C
C Date: December, 1992 C
C C
C measures data parallel operations with communication C
C C
C - reduction operations C
C - broadcast operations C
C - shifting opertions C
C - irregular communication C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
program communication
integer nproc, size, npts, nops, op
integer i, j, k, number
parameter (npts = 11, nops = 5)
real time (nops, npts), usec, mflops, mops
cmf$ layout time(:serial,:serial)
write (6,*) 'Input number of processors : '
read (5,*) nproc
call overhead (tover)
write (6,*) '==============================================='
write (6,*) '| |'
write (6,*) '| ADAPTOR BENCHMARK PROGRAM by Thomas Brandes |'
write (6,*) '| |'
write (6,*) '==============================================='
write (6,*) ' '
write (6,*) 'BENCHMARK FOR P = ', nproc
write (6,*) '==============================='
write (6,*) ' '
c
c testing reduction functions
c
write (6,*) ' '
write (6,*) 'ADAPTOR: reduction functions'
write (6,*) '==============================='
write (6,*) ' '
write (6,*) ' r = redop (x(1:size*nproc)) '
write (6,*) ' '
do op = 1, 2
size = 1
do i = 1, npts
call reduction (op, size, nproc, time(op,i))
time(op,i) = time(op,i) - tover
c write (6,*) 'size = ', size, ' time = ', time(op,i)
size = size * 2
end do
if (op .eq. 1) write (6,*) 'r = sum(x) (1 Flop)'
if (op .eq. 2) write (6,*) 'r = minval(x) (1 Flop)'
write (6,*) ' size usec MOps (1) MOps(all)'
do i = 1, npts
size = 2**(i-1)
usec = time(op,i) * 1e6
mflops = 1e-6*size/time(op,i)
write (6, '(i6,f10.0,2f9.3)') size, usec, mflops, mflops*nproc
end do
write (6,*)
end do
c
c testing replicate/broadcast functions
c
write (6,*) ' '
write (6,*) 'ADAPTOR: replicate functions'
write (6,*) '==============================='
write (6,*) ' '
write (6,*) ' x (1:size, 1:nproc) distributed '
write (6,*) ' '
do op = 1, 4
size = 1
do i = 1, npts
call replicate (op, size, nproc, time(op,i))
time(op,i) = time(op,i) - tover
c write (6,*) 'size = ', size, ' time = ', time(op,i)
size = size * 2
end do
if (op .eq. 1) then
write (6,*) 'replicate every single elements'
write (6,*) 'r1 = x(i,j), i=1:size, j=1:nproc'
number = size * nproc
else if (op .eq. 2) then
write (6,*) 'replicate every column (one process sends)'
write (6,*) 'r2 = x(1:size,j), j=1:nproc'
number = nproc
else if (op .eq. 3) then
write (6,*) 'replicate every row'
write (6,*) 'r3 = x(i,1:nproc), i=1:size'
number = size
else if (op .eq. 4) then
write (6,*) 'full replicate'
write (6,*) 'r4 = x(1:size,1:nproc)'
number = 1
end if
write (6,*) ' size usec #rep usec/#rep kBytes/s '
do i = 1, npts
size = 2**(i-1)
usec = time(op,i) * 1e6
if (op .eq. 1) number = size * nproc
if (op .eq. 2) number = nproc
if (op .eq. 3) number = size
if (op .eq. 4) number = 1
mflops = 4 * size * nproc * 1e-3 / time(op,i)
write (6, '(i6,f10.0,i6,f10.0,f12.2)') size, usec, number,
& usec/number, mflops
end do
write (6,*)
end do
c
c testing circular shift operation
c
do op = 1, 2
size = 1
do i = 1, npts
call mcshift (op, size, nproc, time(op,i))
time(op,i) = time(op,i) - tover
size = size * 2
end do
write (6,*) ' '
if (op .eq. 1) write (6,*)
$ 'ADAPTOR: CSHIFT data parallel operation'
if (op .eq. 2) write (6,*)
$ 'ADAPTOR: EOSHIFT data parallel operation'
write (6,*) '======================================='
write (6,*) ' size usec kB/s kB/s (total)'
do i = 1, npts
size = 2**(i-1)
usec = time(op,i) * 1e6
mflops = 4 * size * 1e-3 / time(op,i)
write (6, '(i6,f10.0,2f12.2)') size, usec,
& mflops, mflops * nproc
end do
write (6,*)
end do
c
c testing irregular communication operation
c
write (6,*) 'ADAPTOR: irregular communication patterns'
write (6,*) '========================================='
write (6,*) ' '
write (6,*) 'real x(size * nproc), z (size * nproc)'
write (6,*) 'integer p (size * nproc)'
do op = 1, 3
size = 1
do i = 1, npts
call mirregular (op, size, nproc, time(op,i))
time(op,i) = time(op,i) - tover
size = size * 2
end do
write (6,*) ' '
if (op .eq. 1) write (6,*) 'z = x(p), p = 1:nproc*size'
if (op .eq. 2) write (6,*) 'z = x(p), p = nproc*size:1:-1'
if (op .eq. 3) write (6,*) 'z = x(p), p = random'
write (6,*) ' '
write (6,*) ' size usec kB/s kB/s (total)'
do i = 1, npts
size = 2**(i-1)
usec = time(op,i) * 1e6
mflops = 4 * size * 1e-3 / time(op,i)
write (6, '(i6,f10.0,2f12.2)') size, usec,
& mflops, mflops * nproc
end do
write (6,*)
end do
write (6,*) 'Benchmark ready'
end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C measure reductions C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
subroutine reduction (op, size, nproc, time)
integer op, size, nproc
real time, t0, t1
real x(size*nproc), result
integer i, nloop
x = 3.0
nloop = 1
10 if (op .eq. 1) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy1 (x, x, x)
result = sum (x)
end do
call walltime (t1)
check = result
else if (op .eq. 2) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy1 (x, x, x)
result = minval (x)
end do
call walltime (t1)
check = result
else
write (6,*) 'operation error in intrinsics'
end if
time = t1 - t0
call nloopupdate (time, nloop)
if (nloop .gt. 0) goto 10
c write (6,*) 'Reduction = ', op, ' Check = ', check
end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C measure replications C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
subroutine replicate (op, size, nproc, time)
integer op, size, nproc
real time, t0, t1
real x(size,nproc), result2 (size), result3 (nproc)
real result1, result4 (size,nproc)
cmf$ layout result2 (:serial), result3 (:serial), result4(:serial)
integer i, j, k, nloop
x = 3.0
nloop = 1
10 if (op .eq. 1) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
do k = 1, size
do j = 1, nproc
result1 = x(k,j)
end do
end do
end do
call walltime (t1)
check = result1
else if (op .eq. 2) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
do j = 1, nproc
result2 (1:size) = x(1:size,j)
end do
end do
call walltime (t1)
check = result2 (1)
else if (op .eq. 3) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
do j = 1, size
result3 (1:nproc) = x(j,1:nproc)
end do
end do
call walltime (t1)
check = result3 (1)
else if (op .eq. 4) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
result4 = x
end do
call walltime (t1)
check = result4 (1,1)
else
write (6,*) 'operation error in replicate'
end if
time = t1 - t0
call nloopupdate (time, nloop)
if (nloop .gt. 0) goto 10
c write (6,*) 'Replicate = ', op, ' Check = ', check
end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C measure circular shifts C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
subroutine mcshift (op, size, nproc, time)
integer op, size, nproc
real time, t0, t1
real x(size,nproc)
integer i, nloop
forall (j=1:nproc,i=1:size) x(i,j) = float(i) / (2 * float(j) + 1)
nloop = 1
10 if (op .eq. 1) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
x = cshift (x, 2, 1)
end do
call walltime (t1)
else if (op .eq. 2) then
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy2 (x)
x(1:size,1:nproc-1) = x(1:size,2:nproc)
x(1:size,nproc) = 0.0
end do
call walltime (t1)
else
write (6,*) 'operation error in mcshift'
end if
time = t1 - t0
call nloopupdate (time, nloop)
if (nloop .gt. 0) goto 10
end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C measure irregular communicats C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
subroutine mirregular (op, size, nproc, time)
integer op, size, nproc
real time, t0, t1
real x(size*nproc), z(size*nproc)
integer p(size*nproc)
integer i, nloop
x = 1.5
if (op .eq. 1) then
forall (i=1:size*nproc) p(i) = i
else if (op .eq. 2) then
forall (i=1:size*nproc) p(i) = size*nproc+1-i
else if (op .eq. 3) then
call cmf_random (p,size*nproc)
p = p + 1
else
write (6,*) 'operation error in mirregular'
end if
nloop = 1
10 call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy1 (x,z,z)
z = x(p)
end do
call walltime (t1)
time = t1 - t0
call nloopupdate (time, nloop)
if (nloop .gt. 0) goto 10
end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C loop handling C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
subroutine nloopupdate (time, n)
real time, runtime
parameter (runtime = 1.0)
integer n
if (time .lt. 0.1) then
n = n * 10
else if (time .lt. (runtime / 2.0)) then
n = n * (runtime / time)
else
time = time / n
n = 0
end if
end
c the next subroutine measures the loop overhead
subroutine overhead (tover)
real tover, t0, t1, x
integer nloop
nloop = 100000
call walltime (t0)
do i = 1, nloop
if (i .gt. nloop) call dummy (x)
end do
call walltime (t1)
tover = (t1 - t0) / nloop
write (6,*) 'Loop overhead ', tover, ' sec'
end
subroutine dummy (x)
real x
print *, 'error'
end
subroutine dummy1 (x, y, z)
real x(10), y(10), z(10)
print *, 'error'
end
subroutine dummy2 (x)
real x(10,10)
print *, 'error'
end